<h1><?=$this->title;?></h1>
<?
    $this->messages();

    $result = $this->search_result;
    if (!empty($result))
    {
?>
<div class="results">
<?
        foreach ($result as $res)
        {
?>
    <div class="table_item">
        <?
        $parent_id = $res->getParentID();
        $menu_data = $res->getMenuData();
        if ($menu_data["open_level"] > 1)
        {
            switch ($menu_data["menu_name"])
            {
                case "accounts":
                    $menu_params = "company_id: ".$menu_data["company_id"].", controller: 'accounts', level: EXPAND_ACCOUNTS_IN_COMPANY";
                break;

                case "view_by_company":
                    $menu_params = "controller: 'viewbycompany', type_id: ".$menu_data["type_id"].", company_id: ".$menu_data["company_id"].", level: EXPAND_VIEW_BY_COMPANY_SPA";
                break;
            }
        }
        ?>
        <span class="pointer" onclick="navigateMenu('<?=$menu_data["menu_name"];?>', <?=$menu_data["level"];?>); <?if ($menu_params){?>expandMenu({<?=$menu_params;?>});<?}?> ajax<?=$res->getOpenItemFunctionName();?>({id: <?=$res->getId();?>, action: 'edit', container: 'inner', no_apply: true <?if ($parent_id){echo ", company_id: ".$parent_id;}?>});">
            <?=$res->getResultName();?>
        </span><br>
<?
            $result_array = $res->getResult();
            foreach ($result_array as $field_name => $result_item)
            {
?>
                <div>
                    <b><?=$field_name?>:</b><?="  ".$result_item?>
                </div>
<?                
            }
?>
    </div>
<?
        }
?>
</div>
<?
    }
?>
<div id="container" style="margin-top: 80px;"></div>